<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/10/12
 * Time: 8:48
 */

namespace app\portal\controller;
use cmf\controller\HomeBaseController;
use app\portal\model\ActivityModel;
use app\portal\model\DocumentCategoryModel;
use app\portal\model\DocumentModel;

use think\Db;

class TrainController extends HomeBaseController
{
    //文档列表
    public function index(){
        if(request()->isAjax()){
            $type_id=input('type_id');
            $list=get_list($type_id);
            return json(['list'=>$list,'page'=>$list->render()]);
        }else{
            $list_1 = get_list(18);
            $list_2 = get_list(19);
            $list_3 = get_list(20);
            $list_4 = get_list(21);
            $this->assign('list_1', $list_1);
            $this->assign('list_2', $list_2);
            $this->assign('list_3', $list_3);
            $this->assign('list_4', $list_4);
            return $this->fetch(':voluntTrain');
        }
    }
    //培训文档详情
    public function detail(){
        $id=input('id');
        $model = new DocumentModel();
        $data=$model->where('id',$id)->find();
        $data['file_urls']=json_decode($data['file_urls']);
        $data['file_names']=json_decode($data['file_names']);
        $data['post']=json_decode($data['post'],true);
        $this->assign('data',$data);
        return $this->fetch(':voluntDetail');
    }

}